package similan.br18.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;

import similan.br18.domain.Contact;
import similan.br18.domain.Group;

@ManagedBean
@ApplicationScoped
public class ContactService {

	public List<Contact> getContactsByGroup(Contact contact, Group group) {

		// use group and contacts here...
		List<Contact> contacts = new ArrayList<Contact>();
		for (Contact c : contact.getContacts()) {
			if (new Random().nextBoolean()) {
				contacts.add(c);
			}
		}

		return contacts;
	}

	public List<Contact> getContactsByGroupAndFilterText(Contact contact,
			Group group, String filterText) {
		// filter by group and filterText
		List<Contact> contacts = new ArrayList<Contact>();
		for (Contact c : contact.getContacts()) {
			if (new Random().nextBoolean()) {
				contacts.add(c);
			}
		}

		return contacts;
	}
}
